package com.labManage.service.impl;

import com.labManage.dao.LogDao;
import com.labManage.entity.Goods;
import com.labManage.entity.Log;
import com.labManage.entity.User;
import com.labManage.service.LogService;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class LogServiceImpl implements LogService {

    @Autowired
    LogDao logDao;
    @Override
    public List<Log> getLogList(Integer page, Integer limit, Log log) {
        Subject subject = SecurityUtils.getSubject();
        User loginUser = (User) subject.getPrincipal();
        int startIndex = (page - 1) * limit;
        List<Log> logs = logDao.selectLogLimit(startIndex, limit, log);
        return logs;
    }

    @Override
    public List<Log> getRecentlyBorrowLog() {
        Subject subject = SecurityUtils.getSubject();
        User loginUser = (User) subject.getPrincipal();
        if(loginUser!=null){
            List<Log> logInfos = logDao.selectLogByBorrowPersonNo(loginUser.getUserNo());
            return logInfos;
        }else {
            return null;
        }
    }
}
